package com.sys.controller;

import com.sys.pojo.Khmc;
import com.sys.service.KhmcService;

import com.sys.tools.DataTreeResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@Controller
public class KhmcController {
    @Autowired
    private KhmcService khmcService;
    @RequestMapping("main")
    public String main(){return "main";}

    @RequestMapping("khgl")
    public String khgl(){return "khgl";}

    @RequestMapping("/khmc/getAll")
    @ResponseBody
    public List<DataTreeResult> getAll()throws RuntimeException{
        List<Khmc>list=khmcService.getAll();
        List<DataTreeResult>result =new ArrayList<DataTreeResult>();
        result.add(new DataTreeResult(Long.valueOf(0),"所有用户","open","",null));
        for (Khmc khmc: list){
            result.add(new DataTreeResult(Long.valueOf(khmc.getKhmcId()),khmc.getKhmcName(),"closed","",Long.parseLong("0")));
        }
        return result;
    }
}
